--------- MODULE piesejas ------------

EXTENDS Integers, Naturals, Sequences, TLC, FiniteSets

Last(seq) == seq[Len(seq)]

Empty(seq) == Len(seq) = 0

RECURSIVE Take(_,_)
Take(n, seq) == CASE n = 0 -> <<>>
  [] n = 1 -> <<Head(seq)>>
  [] n >= 2 -> Take(1, seq) \o Take(n-1, Tail(seq))

RECURSIVE Drop(_,_)
Drop(n, seq) == CASE n = 0 -> seq
  [] n = 1 -> Tail(seq)
  [] n >= 2 -> Drop(n-1, Drop(1, seq))

(*--algorithm piesejas
variables
(*
  period \in {1,5,10,30}
  starting_time \in 0..100
  candle_count \in 1 .. 10
  *)

define
end define;

fair process market_database
  variable subscriptions = [client -> 
begin
MarketDatabase:
  either
    /* download history
    skip;
  or
    /* update with incoming trades
    skip;
  or
    /* subscribe new client
    skip;
  or
    /* push history
    skip;
  or
    /* push updates
    skip;
  end either;
end process;

end algorithm;*)

===========

MarketDatabase
  - leidzia
    - klientam gauti istorijos atkarpa
      - desine norimo periodo puse nebutinai turi baigtis dabartimi
        - tai gali buti periodas praeityje
    - ir/arba klausyti ateinancios informacijos
